package 富婆梦.第一阶段.第七周IO流;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.nio.channels.FileChannel;

/**
 * @ProjectName: java-learning
 * @Package: 富婆梦.第一阶段.第七周
 * @ClassName: TransferTo
 * @Author: hemengjin
 * @Description: nio：连接两个通道用于同时读和写
 * @Date:2021/9/12 22:16
 * @Version: 1.0
 */
public class TransferTo {
    public static void main(String[] args) throws Exception {
        if (args.length != 2) {
            System.out.println("argument:sourcefile destfile");
            System.exit(1);
        }
        FileChannel
                in=new FileInputStream(args[0]).getChannel(),
                out=new FileOutputStream(args[1]).getChannel();
        in.transferTo(0,in.size(),out);
    }
}
